export function os() {
  return uni.getSystemInfoSync().platform;
}

export function sys() {
  return uni.getSystemInfoSync();
}

/**
 * 版本号比对
 * @param {*} v1
 * @param {*} v2
 * @returns
 */
export function compareVersion(v1, v2) {
  let cpResult;
  let i = 0;
  const arr1 = v1.replace(/[^0-9.]/, "").split(".");
  const arr2 = v2.replace(/[^0-9.]/, "").split(".");
  while (true) {
    const s1 = arr1[i];
    const s2 = arr2[i++];
    if (s1 === undefined || s2 === undefined) {
      cpResult = arr1.length - arr2.length;
      break;
    }
    if (s1 === s2) continue;
    cpResult = s1 - s2;
    break;
  }
  // eslint-disable-next-line
  return cpResult > 0 ? 1 : cpResult === 0 ? 0 : -1;
}
